home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_065 / menubuilder / menubuilder.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  17KB  |  704 lines

  1. /*
  2.   This Software is Copyrighted 1986 by Custom Services
  3.   All rights to this and the generated data are the property
  4.   of Custom Services and may not be used for Commercial purposes
  5.   without the express written consent of Custom Services.
  6.  
  7.  
  8.   Menu Builder V1.0
  9.  
  10.   Due to the difficulty in building menus that work I attempted to
  11.   automate the problem.  I wanted a standard interface to the menu
  12.   process with a program generating all the obvious values.
  13.  
  14.   This program takes a simple sequential file and generates the Menu
  15.   structures for a program.
  16.  
  17.   Input:
  18.  
  19.   MENU,Name
  20.   ITEM,Name,[Select],[Command]
  21.   SUBI,Name,[Select],[Command]
  22.  
  23.   Position and Flags will be set to a reasonable default.  The User
  24.   may Edit the resulting source to modify the options.
  25.  
  26.   Name is the name of the Menu, item or Sub item.
  27.  
  28.   Select is an optional item which will display when the item is
  29.   clicked upon.
  30.   
  31.   Command is the Character to use for selection of the menu item with
  32.   the AMIGA key.  A check will be made to see that characters are not
  33.   used more than once.  Only single letters A-Z are allowed.  The letters
  34.   M and N are not allowed since Intuition uses these for screen control.
  35.  
  36.   The positioning of a menu will be automatically calculated based on the
  37.   length of the strings used in the menu.  The widest string will be used
  38.   to base the width.  Most of this processing is contained in the routine
  39.   Do_Output, Change it's parameters as needed.
  40.  
  41.   Output: Standard C source file compilable as is!
  42.  
  43.   The struct's Menu, MenuItem, and IntuiText will be generated as
  44.   needed to define the Menu's based on the input file.
  45.  
  46.   You will need to include the statement:
  47.  
  48.   extern struct Menu *MyMenu;
  49.  
  50.   In your source program and call:
  51.  
  52.   SetMenuStrip(window ptr,MyMenu);
  53.  
  54.   Also, before you close your window you must call:
  55.  
  56.   ClearMenuStrip(window ptr);
  57.  
  58.   or risk a spectacular crash.  I don't know why Intuition doesn't
  59.   do this automatically when you close a window with a menu!  
  60.  
  61.  
  62.  
  63. */
  64. #define  EOS       0
  65. #define  CHAR_WIDTH  8
  66.  
  67. #include <libraries/dos.h>
  68. #include <lattice/stdio.h>
  69. #include <intuition/intuition.h>
  70.  
  71. #define NO_ERROR         0
  72. #define ERROR_NO_COMMA   1
  73. #define ERROR_BAD_TEXT   2
  74. #define ERROR_NO_MENU    3
  75. #define ERROR_NO_ITEM    4
  76. #define ERROR_NO_DATA    5
  77. #define ERROR_BAD_NUMBER 6
  78. #define ERROR_BAD_COMMAND 7
  79. #define MAX_LINE  132
  80.  
  81. char cline[MAX_LINE];      /* input line                   */
  82. char RecBuf[BUFSIZ];      /* input buffer                 */
  83. char *name1;              /* File name pointer            */
  84. int  EndOfFile;           /* true = end of file           */
  85. int  lastreadsize;        /* last read buffer size        */
  86. int  sptr;                /* current buffer pointer       */
  87. int  lcnt;                /* current input line count     */
  88.  
  89. int Flgs[26];             /* Selected Options from Do_Arguments */
  90.  
  91.  
  92. struct IntuiText *CText;   /* Current Text Item pointer */
  93. struct IntuiText *AllText; /* All text items */
  94. struct MenuItem  *CItem;   /* Current Menu Item */
  95. struct MenuItem  *CSItem;   /* Current Sub Menu Item */
  96. struct Menu      *CMenu, *AllMenu; /* Menu pointers */
  97.  
  98.  
  99. main(argc, argv)
  100.  
  101.   int   argc;                      /*number of arguments            */
  102.   char  *argv[];                   /*array of ptrs to arg strings   */
  103.  
  104.   {
  105.   FILE  *Open();
  106.   FILE  *file1;                    /* input File pointer                 */
  107.   int j, i;
  108.   int result,error;
  109.   char *Scan();
  110.   int  GetLine();
  111.   char *cptr;
  112.  
  113. /* get the file names and open the files */
  114. /* initialize input buffers and variables*/
  115.  
  116.   AllText = NULL;
  117.   CText   = NULL;
  118.   CMenu   = NULL;
  119.   CItem   = NULL;
  120.   CSItem  = NULL;
  121.   AllMenu = NULL;
  122.   result = NO_ERROR;
  123.   error  = 0;
  124.   Do_Arguments(argc,argv);     /* process arguments */
  125.  
  126.   for (name1 = NULL, i=1; i<argc && name1 == NULL; i++)
  127.     if ( *argv[i] != '-') name1 = argv[i];
  128.  
  129.   lcnt = 0;
  130.   sptr = BUFSIZ;     /* Set up first Read */
  131.   EndOfFile = FALSE; /* no end of file  */
  132.  
  133.   file1      = Open(name1,MODE_OLDFILE);  /* open file for reading */
  134.   if ( file1 == NULL )
  135.     {
  136.     printf(" Cannot get file open: %s\n",name1);
  137.     exit(10);
  138.     };
  139.  
  140.   while (  ( j = GetLine(file1,cline) ) > 0)
  141.     {
  142.     if ( Flgs[3] )
  143.       {
  144.       printf("Main:%s:%d:%8x:%8x:%8x\n",cline,j,CMenu,CItem,CSItem);
  145.       };
  146.     cptr = &cline[0];
  147.     if(       strncmp("MENU",cptr,4) == 0 )
  148.       {
  149.       cptr = Scan(cptr,',',TRUE);
  150.       result = Process_Menu(cptr);
  151.       }
  152.     else if ( strncmp("ITEM",cptr,4) == 0 )
  153.       {
  154.       cptr = Scan(cptr,',',TRUE);
  155.       result = Process_Item(cptr,0);  /* do an Item */
  156.       }
  157.     else if ( strncmp("SUBI",cptr,4) == 0 )
  158.       {
  159.       cptr = Scan(cptr,',',TRUE);
  160.       result = Process_Item(cptr,1);  /* do a Sub Item */
  161.       }
  162.     else  /* error, bad command */
  163.       {
  164.       result = ERROR_BAD_COMMAND;
  165.       if(  Flgs[3] ) printf(" Invalid Input at line %d\n",lcnt);
  166.       };
  167.     if( result != NO_ERROR )
  168.       {
  169.       error++;
  170.       printf(" Line %d has syntax error:%s\n",lcnt,cptr);
  171.       };
  172.     };
  173.   Close(file1);
  174.   if( error == 0 ) Do_Output();
  175.   }
  176.  
  177. char *Scan(ptr,c,control)
  178.   char *ptr;
  179.   char c;
  180.   int control;
  181.  
  182.   {
  183.  
  184.   while ( *ptr != NULL
  185.      && ( ( control && *ptr != c ) || ( ! control && *ptr == c) ) )
  186.      ptr++;
  187.  
  188.   return( ptr );  /* return the new pointer */
  189.   }
  190.  
  191. GetLine(fptr,line)     /* get a line from buffer */
  192.  
  193.   FILE *fptr;                   /* file pointer if a read is needed*/
  194.   char line[];                 /* destination of characters       */
  195.  
  196.   {
  197.   char c;
  198.   int idx;
  199.   lcnt++;         /* bump line count*/
  200.   for (idx = 0; idx < MAX_LINE; idx++ )
  201.     line[idx] = EOS;           /* fill line with EOS's            */
  202.  
  203.   if ( sptr >= lastreadsize ) /* buffer is empty so read one     */
  204.     {
  205.     if ( EndOfFile )
  206.       {
  207.       return(0);  /* no more to read?*/
  208.       };
  209.     lastreadsize = Read(fptr, RecBuf, sizeof(RecBuf));  /* read buffer */
  210.     if (lastreadsize != sizeof(RecBuf) )
  211.       {
  212.       EndOfFile = TRUE;
  213.       };
  214.     sptr = 0;
  215.     };
  216.  
  217.   for( idx=0; idx < MAX_LINE && sptr < lastreadsize ; )
  218.     {
  219.     c = RecBuf[sptr++];
  220.     if (c != 10 && c != EOS )
  221.       line[idx++] = c;            /* move data */
  222.     else
  223.       {
  224.       while ( sptr < lastreadsize
  225.              && (RecBuf[sptr] == EOS | RecBuf[sptr] == 10) )
  226.         sptr++;
  227.       return(idx);
  228.       };
  229.     };
  230.   if(idx == MAX_LINE | EndOfFile )return(idx);
  231.   lastreadsize = Read(fptr, RecBuf, sizeof(RecBuf));/* read  buffer */
  232.   if (lastreadsize != sizeof(RecBuf) )
  233.     {
  234.     EndOfFile = TRUE;
  235.     };
  236.   sptr = 0;
  237.   for ( ;idx < MAX_LINE; )
  238.     {
  239.     c = RecBuf[sptr++];
  240.     if (c != 10 && c != EOS )
  241.       line[idx++] = c;           /* move data */
  242.     else
  243.       {
  244.       while ( sptr < lastreadsize
  245.             && (RecBuf[sptr] == EOS | RecBuf[sptr] == 10) )
  246.         sptr++;
  247.       return(idx);
  248.       };
  249.     };
  250.   return(idx);
  251.   }
  252.  
  253. int Process_Menu(ptr)
  254.   char *ptr;
  255.   {
  256.   char *tptr;
  257.   int len;
  258.   struct Menu *last;
  259.  
  260.   if( AllMenu == NULL )
  261.     { /* first menu item */
  262.     AllMenu = ( struct Menu *)malloc(sizeof(struct Menu));
  263.     CMenu = AllMenu; /* Set current pointer */
  264.     }
  265.   else
  266.     { /* add new one to list */
  267.     last = CMenu;
  268.     CMenu = (struct Menu *)malloc(sizeof(struct Menu));
  269.     last->NextMenu = CMenu;
  270.     };
  271.  
  272. /* Build Menu structure */
  273.  
  274.   if( *ptr != ',')return(ERROR_NO_COMMA);
  275.   ptr++;
  276.  
  277.   tptr = Scan(ptr,' ',TRUE); /* find end of string */
  278.   len  = tptr-ptr;
  279.   CMenu->MenuName = (BYTE *)malloc(len+1);
  280.   stpcpy(CMenu->MenuName,ptr,len);
  281.   ptr +=len;
  282.   *ptr = '\0';  /* make sure it is a proper string!*/
  283.   CMenu->NextMenu = NULL;
  284.   CMenu->FirstItem= NULL;
  285.   CItem = NULL;
  286.   CMenu->Width = len + 3 ;
  287.   return(NO_ERROR);
  288.   }
  289.  
  290. int Process_Item(ptr,type)
  291.   char *ptr;
  292.   int type;    /* 0 = ITEM, 1 = SUB ITEM */
  293.  
  294.   {
  295.   struct IntuiText *Process_Text();
  296.   struct MenuItem *ThisItem;
  297.   struct MenuItem *lastI;
  298.   struct MenuItem *lastSI;
  299.  
  300.   if( CMenu == NULL )             return(ERROR_NO_MENU);
  301.   if( type == 1 && CItem == NULL )return(ERROR_NO_ITEM);
  302.   if( *ptr != ',' )               return(ERROR_NO_COMMA);
  303.   if( type == 0 )
  304.     { /* do an item building a MenuItem */
  305.  
  306.     lastI = CItem;
  307.     CSItem= NULL;  /* clear current Sub Item Flag */
  308.     CItem = (struct MenuItem *)malloc(sizeof(struct MenuItem));
  309.     if( Flgs[3] ) printf("ITEM: %8x %8x %8x\n",lastI,CMenu->FirstItem,CItem);
  310.  
  311.     if( lastI == NULL )
  312.       { /* First Item for Menu */
  313.       CMenu->FirstItem = CItem;  /* link it to the menu */
  314.       }
  315.     else
  316.       {
  317.       lastI->NextItem = CItem;   /* link it to the item list */
  318.       };
  319.     ThisItem = CItem;   /* build it */
  320.     }
  321.   else
  322.     {   /* Do a Sub Item */
  323.  
  324.     lastSI = CSItem;
  325.     CSItem = (struct MenuItem *)malloc(sizeof(struct MenuItem));
  326.     if( Flgs[3] ) printf("SUBI: %8x %8x %8x\n",lastSI,CItem->SubItem,CSItem);
  327.     if( lastSI == NULL )
  328.       { /* First Sub Item for Menu Item */
  329.       CItem->SubItem = CSItem; /* link in the sub items */
  330.       }
  331.     else
  332.       {
  333.       lastSI->NextItem = CSItem;
  334.       };
  335.     ThisItem = CSItem;
  336.     };
  337.  
  338. /* Process name select and command */
  339.  
  340.   ptr++;
  341.    
  342.   ThisItem->ItemFill = ( APTR )Process_Text(ptr);
  343.   if( Flgs[0] )printf("ItemFill:%8x\n",ThisItem->ItemFill);
  344.   if( ThisItem->ItemFill == NULL )return(ERROR_BAD_TEXT);
  345.  
  346.   ptr = Scan(ptr,',',TRUE); /* find next comma */
  347.   if( *ptr != ',')return(ERROR_NO_COMMA);
  348.   ptr++;
  349.  
  350. /* Select name? */
  351.  
  352.   ThisItem->SelectFill = ( APTR )Process_Text(ptr);
  353.   if( Flgs[0] )printf(" SelectFill:%8x\n",ThisItem->SelectFill);
  354.  
  355.   ptr = Scan(ptr,',',TRUE); /* find next comma */
  356.   if( *ptr != ',')return(ERROR_NO_COMMA);
  357.   ptr++;
  358.  
  359. /* Command ? */
  360.   ThisItem->NextItem      = NULL;
  361.   ThisItem->SubItem       = NULL;
  362.   ThisItem->Command       = *ptr;
  363.   ThisItem->MutualExclude = 0L;
  364.   return(NO_ERROR);
  365.   }
  366.  
  367. struct IntuiText *Process_Text(ptr)
  368.   char *ptr;
  369.   {
  370.   struct IntuiText *dptr, *lasText;
  371.   char *tptr;
  372.  
  373.   if( *ptr == ',')return(NULL);
  374.  
  375.   lasText = AllText;
  376.   while( lasText != NULL)
  377.     {
  378.     CText = lasText;
  379.     lasText = lasText->NextText;
  380.     };
  381.   lasText = CText;
  382.   CText = (struct IntuiText *)malloc(sizeof(struct IntuiText));
  383.   CText->NextText = NULL;
  384.   if( Flgs[0] )
  385.     {
  386.     printf("lasText:%8x CText:%8x ptr:%s\n",lasText,CText,ptr);
  387.     };
  388.   if( AllText == NULL )
  389.     {
  390.     AllText = CText;
  391.     }
  392.   else
  393.     {
  394.     lasText->NextText = CText;
  395.     };
  396.  
  397.   tptr = Scan(ptr,',',TRUE);
  398.  
  399.   CText->IText = (UBYTE *)malloc(tptr-ptr+1);
  400.  
  401.   if( Flgs[0] )printf("Length:%d IText:%8x ptr:%8x tptr:%8x\n"
  402.     ,tptr-ptr+1,CText->IText,ptr,tptr);
  403.  
  404.   strncpy(CText->IText,ptr,tptr-ptr);
  405.  
  406.   if( CMenu->Width <= tptr-ptr )CMenu->Width = tptr-ptr;
  407.  
  408.   if( Flgs[0] )printf("len=%d Max:%d IText:%s\n",
  409.      strlen(CText->IText),CMenu->Width,CText->IText);
  410.  
  411. /* check for duplicate, eliminate this one if duplicate */
  412.   
  413.   dptr = AllText;
  414.   while ( dptr != CText )
  415.     {
  416.     if( Flgs[0] )
  417.       {
  418.       printf(" dptr:%8x->%s\n",dptr->IText,dptr->IText);
  419.       };
  420.     if ( strcmp(dptr->IText,CText->IText) == 0 )
  421.       {
  422.       if( Flgs[0] )
  423.         {
  424.         printf(" Duplicate:%8x %8x %s\n",
  425.                dptr,CText,dptr->IText);
  426.         };
  427.       free( (char *)(CText->IText) );
  428.       free( (char *) CText         );
  429.       CText = dptr;
  430.       lasText->NextText = NULL;
  431.       }
  432.     else
  433.       {
  434.       dptr = dptr->NextText;
  435.       };
  436.     };
  437.   if( Flgs[0] ) printf("Processed Text: %8x:%s\n",CText,CText->IText);
  438.   return(CText);
  439.   }
  440.  
  441. Do_Output()
  442.   {
  443.   char nxt,quote,FLAG;
  444.   char Mptr[14];
  445.   int Menu, Item, left, top, width, height;
  446.   int stop;
  447.   char rest[60];
  448.  
  449. /* Output the IntuiText structure first */
  450.  
  451.   quote = '"';
  452.   printf("/***************************************/\n");
  453.   printf("/* Copyrighted by Custom Services 1986 */\n");
  454.   printf("/***************************************/\n");
  455.   printf("#include <exec/types.h>\n");
  456.   printf("#include <intuition/intuition.h>\n");
  457.  
  458.   CText = AllText;
  459.   if( AllText != NULL)
  460.     {
  461.     printf("\nstruct IntuiText IText[] =\n");
  462.     printf("  {\n");
  463.     };
  464.  
  465.   while( CText != NULL ) /* for all text to output */
  466.     {
  467.     if( CText->NextText == NULL)
  468.       {
  469.       nxt = ' ';
  470.       }
  471.     else
  472.       {
  473.       nxt = ',';
  474.       };
  475.     printf("    { 0, 1, JAM2, CHECKWIDTH, 0, NULL, %c%s%c}%c\n",
  476.       quote,CText->IText,quote,nxt);
  477.     CText = CText->NextText;
  478.     };
  479.  
  480.   if( AllText != NULL )
  481.     {
  482.     printf("  };\n");
  483.     };
  484.   printf("\n#define EXTRA  CHECKWIDTH\n");
  485.   printf("#define FLAGSA CHECKIT|ITEMTEXT|MENUTOGGLE|ITEMENABLED\n");
  486.   printf("#define FLAGSB CHECKIT|ITEMTEXT|MENUTOGGLE|ITEMENABLED|COMMSEQ\n\n");
  487.  
  488.   CMenu = AllMenu;
  489.   Menu = 0;
  490.   left = 0;
  491.   Item = 0;
  492.   height = 10;
  493.  
  494.   while ( CMenu != NULL )
  495.     {
  496.     Item = 0;
  497.     CItem = CMenu->FirstItem;
  498.     while ( CItem != NULL)
  499.       {
  500.       CSItem = CItem->SubItem;
  501.       if ( CSItem != NULL ) Do_Out_Sub(Menu,Item);
  502.       Item++;
  503.       CItem = CItem->NextItem;
  504.       };
  505.     Menu++;
  506.     CMenu = CMenu->NextMenu;
  507.     }
  508.   CMenu = AllMenu;
  509.   Menu = 0;
  510.   left = 0;
  511.   Item = 0;
  512.   height = 10;
  513.  
  514.   while ( CMenu != NULL )
  515.     {
  516.     Item = 0;
  517.     CItem = CMenu->FirstItem;
  518.     CSItem = CItem->SubItem;
  519.     top  = 0;
  520.     printf("struct MenuItem M%d[] = \n",Menu);
  521.     printf("  {\n");
  522.     top  = 0;
  523.     width =  CMenu->Width * CHAR_WIDTH;
  524.  
  525.     while ( CItem != NULL )
  526.       {
  527.       Item++;
  528.       CSItem = CItem->SubItem;
  529.       if( CItem->NextItem == NULL )
  530.         {
  531.         sprintf(Mptr,"NULL   ");
  532.         nxt = ' ';
  533.         }
  534.       else
  535.         {
  536.         sprintf(Mptr,"&M%d[%2d]",Menu,Item);
  537.         nxt = ',';
  538.         };
  539.       if( CItem->SelectFill == NULL)
  540.         {
  541.         sprintf(rest,"NULL            ,");
  542.         }
  543.       else
  544.         {
  545.         sprintf(rest,"(APTR)&IText[%2d],",Index(CItem->SelectFill));
  546.         };
  547.  
  548.       if( CItem->Command == NULL || CItem->Command == ' ')
  549.         {
  550.         sprintf(&rest[17],"NULL,");
  551.         FLAG = 'A';
  552.         }
  553.       else
  554.         {
  555.         sprintf(&rest[17]," '%c',",CItem->Command);
  556.         FLAG = 'B';
  557.         };
  558.  
  559.       if( CSItem == NULL )
  560.         {
  561.         sprintf(&rest[22],"NULL");
  562.         }
  563.       else
  564.         {
  565.         sprintf(&rest[22],"&M%dI%d[0]",Menu, (Item-1) );
  566.         };
  567.  
  568.       printf("    {%s,%3d,%3d,%3d+EXTRA,%3d,FLAGS%c,0,",
  569.                   Mptr,left,top,width,height,FLAG);
  570.       printf("(APTR)&IText[%2d],%s}%c\n",Index(CItem->ItemFill),rest,nxt);
  571.       CItem = CItem->NextItem;
  572.       top   = top + height + 2;
  573.       };
  574.     printf("  };\n\n");
  575.     CMenu = CMenu->NextMenu;
  576.     Menu++;
  577.     };
  578.  
  579.   CMenu = AllMenu;
  580.   printf("struct Menu TheMenu[] =\n");
  581.   printf("  {\n");
  582.   left = 0;
  583.   top  = 0;
  584.   Menu = 0;
  585.   
  586.   while ( CMenu != NULL )
  587.     {
  588.     Menu++;
  589.     width = CMenu->Width  * CHAR_WIDTH;
  590.     if( CMenu->NextMenu == NULL )
  591.       {
  592.       sprintf(Mptr,"NULL       ");
  593.       nxt = ' ';
  594.       }
  595.     else
  596.       {
  597.       sprintf(Mptr,"&TheMenu[%2d]",Menu);
  598.       nxt = ',';
  599.       };
  600.     (void)strncpy(rest,"                               ",25);
  601.     stop = CMenu->Width - strlen(CMenu->MenuName);
  602.     if( stop <= 0 )
  603.       {
  604.       (void)strncpy(rest,CMenu->MenuName,25);
  605.       }
  606.     else
  607.       {
  608.       stop = stop/2;
  609.       (void)strncpy(&rest[stop],CMenu->MenuName,25-stop);
  610.       (void)strncat(rest,"                         ",25);
  611.       };
  612.  
  613.     quote = '"';
  614.     height = 10;
  615.     printf("    {%12s,%3d,%3d,%3d+EXTRA,%3d",Mptr,left,top,width,height);
  616.     printf(",MENUENABLED,%c%s%c,&M%d[0]}%c\n",quote,rest,quote,(Menu-1),nxt);
  617.     left = left + width + 4*CHAR_WIDTH;
  618.     CMenu = CMenu->NextMenu;
  619.     };
  620.   printf("  };\n\n");
  621.   printf("struct Menu *MyMenu = &TheMenu[0];");
  622.   }
  623.  
  624. int Index(ptr)   /* Find the position index */
  625.   struct IntuiText *ptr;
  626.   {
  627.   int idx;
  628.  
  629.   idx = 0;
  630.   CText = AllText;
  631.  
  632.   while  ( CText != NULL && ptr != CText)
  633.     {
  634.     if( Flgs[0] )
  635.       {
  636.       printf("Index: %d, %8x:%s\n",idx,CText,CText->IText);
  637.       };
  638.     idx++;
  639.     CText = CText->NextText;
  640.     };
  641.   return(idx);
  642.   }
  643.  
  644. Do_Out_Sub(Menu,Item)
  645.   int Menu, Item;
  646.   { 
  647.   int SItem;
  648.   int stop, width, sleft;
  649.   int top, height;
  650.   char Mptr[14];
  651.   char rest[60];
  652.   char nxt,FLAG;
  653.  
  654.   SItem = 0;
  655.   top = 0;
  656.   height = 10;
  657.   printf("struct MenuItem M%dI%d[] = \n",Menu,Item);
  658.   printf("  {\n");
  659.   width = CMenu->Width*CHAR_WIDTH;
  660.   SItem = 0;
  661.   while ( CSItem != NULL )
  662.     {
  663.     SItem++;
  664.     if( CSItem->NextItem == NULL )
  665.       {
  666.       sprintf(Mptr,"NULL   ");
  667.       nxt = ' ';
  668.       }
  669.     else
  670.       {
  671.       sprintf(Mptr,"&M%dI%d[%2d]",Menu,Item,SItem);
  672.       nxt = ',';
  673.       };
  674.     if( CSItem->SelectFill == NULL )
  675.       {
  676.       sprintf(rest,"NULL            ,");
  677.       }
  678.     else
  679.       {
  680.       sprintf(rest,"(APTR)&IText[%2d],",Index(CSItem->SelectFill));
  681.       };
  682.     if( CSItem->Command == NULL || CSItem->Command == ' ')
  683.       {
  684.       sprintf(&rest[17],"NULL,");
  685.       FLAG = 'A';
  686.       }
  687.     else
  688.       {
  689.       sprintf(&rest[17]," '%c',",CSItem->Command);
  690.       FLAG = 'B';
  691.       };
  692.     sprintf(&rest[22],"NULL");
  693.     sleft =  (width * 7)/10;
  694.     stop  =  top + 2;
  695.     printf("    {%s,%3d,%3d,%3d+EXTRA,%3d,FLAGS%c,0,"
  696.            ,Mptr,sleft,stop,width,height,FLAG);
  697.  
  698.     printf("(APTR)&IText[%2d],%s}%c\n",Index(CSItem->ItemFill),rest,nxt);
  699.     CSItem = CSItem->NextItem;
  700.     top = top + height;
  701.     };
  702.   printf("  };\n\n");
  703.   }
  704.